﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using BPM.Entity;
using System.Data.Entity.ModelConfiguration;

namespace BPM.Service.Mappings
{
	internal class ProductAssembleDefinitionConfiguration : EntityConfiguration<ProductAssembleDefinition>
	{
		public ProductAssembleDefinitionConfiguration()
		{
			this.HasRequired(p => p.User)
				.WithMany()
				.HasConstraint((p, u) => p.UserId == u.Id)
				.WillCascadeOnDelete(false);

			this.HasRequired(p => p.Barcode)
				.WithMany()
				.HasConstraint((p, b) => p.BarcodeId == b.Id)
				.WillCascadeOnDelete(false);

			//this.HasMany(p => p.ItemList).WithMany().Map("ProductAssembleDefinition_Item",
			//    (p, i) => new
			//    {
			//        ProductAssembleDefinitionId = p.Id,
			//        ProductAssembleDefinitionItemId = i.Id
			//    });
		}
	}
}
